home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / u_man / cat3 / Tcl / crtmathfnc.z / crtmathfnc
Encoding:
Text File  |  1998-10-30  |  6.0 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333TTTTccccllll))))                              TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tcl_CreateMathFunc - Define a new math function for expressions
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
  13.  
  14.      TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc(_i_n_t_e_r_p, _n_a_m_e, _n_u_m_A_r_g_s, _a_r_g_T_y_p_e_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a)
  15.  
  16. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  17.      Tcl_Interp      *_i_n_t_e_r_p      (in)      Interpreter in which new function
  18.                                             will be defined.
  19.  
  20.      char            *_n_a_m_e        (in)      Name for new function.
  21.  
  22.      int             _n_u_m_A_r_g_s      (in)      Number of arguments to new
  23.                                             function;  also gives size of
  24.                                             _a_r_g_T_y_p_e_s array.
  25.  
  26.      Tcl_ValueType   *_a_r_g_T_y_p_e_s    (in)      Points to an array giving the
  27.                                             permissible types for each
  28.                                             argument to function.
  29.  
  30.      Tcl_MathProc    *_p_r_o_c        (in)      Procedure that implements the
  31.                                             function.
  32.  
  33.      ClientData      _c_l_i_e_n_t_D_a_t_a   (in)      Arbitrary one-word value to pass
  34.                                             to _p_r_o_c when it is invoked.
  35.  
  36.  
  37. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  38.      Tcl allows a number of mathematical functions to be used in expressions,
  39.      such as ssssiiiinnnn, ccccoooossss, and hhhhyyyyppppooootttt.  TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc allows applications to
  40.      add additional functions to those already provided by Tcl or to replace
  41.      existing functions.  _N_a_m_e is the name of the function as it will appear
  42.      in expressions.  If _n_a_m_e doesn't already exist as a function then a new
  43.      function is created.  If it does exist, then the existing function is
  44.      replaced.  _N_u_m_A_r_g_s and _a_r_g_T_y_p_e_s describe the arguments to the function.
  45.      Each entry in the _a_r_g_T_y_p_e_s array must be either TCL_INT, TCL_DOUBLE, or
  46.      TCL_EITHER to indicate whether the corresponding argument must be an
  47.      integer, a double-precision floating value, or either, respectively.
  48.  
  49.      Whenever the function is invoked in an expression Tcl will invoke _p_r_o_c.
  50.      _P_r_o_c should have arguments and result that match the type TTTTccccllll____MMMMaaaatttthhhhPPPPrrrroooocccc:
  51.           typedef int Tcl_MathProc(
  52.                ClientData _c_l_i_e_n_t_D_a_t_a,
  53.                Tcl_Interp *_i_n_t_e_r_p,
  54.                Tcl_Value *_a_r_g_s,
  55.                Tcl_Value *_r_e_s_u_l_t_P_t_r);
  56.  
  57.      When _p_r_o_c is invoked the _c_l_i_e_n_t_D_a_t_a and _i_n_t_e_r_p arguments will be the same
  58.      as those passed to TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc.  _A_r_g_s will point to an array of
  59.      _n_u_m_A_r_g_s Tcl_Value structures, which describe the actual arguments to the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333TTTTccccllll))))                              TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333TTTTccccllll))))
  71.  
  72.  
  73.  
  74.      function:
  75.           typedef struct Tcl_Value {
  76.                Tcl_ValueType _t_y_p_e;
  77.                long _i_n_t_V_a_l_u_e;                                                 |
  78.                double _d_o_u_b_l_e_V_a_l_u_e;
  79.           } Tcl_Value;
  80.  
  81.      The _t_y_p_e field indicates the type of the argument and is either TCL_INT
  82.      or TCL_DOUBLE.  It will match the _a_r_g_T_y_p_e_s value specified for the
  83.      function unless the _a_r_g_T_y_p_e_s value was TCL_EITHER. Tcl converts the
  84.      argument supplied in the expression to the type requested in _a_r_g_T_y_p_e_s, if
  85.      that is necessary.  Depending on the value of the _t_y_p_e field, the
  86.      _i_n_t_V_a_l_u_e or _d_o_u_b_l_e_V_a_l_u_e field will contain the actual value of the
  87.      argument.
  88.  
  89.      _P_r_o_c should compute its result and store it either as an integer in
  90.      _r_e_s_u_l_t_P_t_r->_i_n_t_V_a_l_u_e or as a floating value in _r_e_s_u_l_t_P_t_r->_d_o_u_b_l_e_V_a_l_u_e.  It
  91.      should set also _r_e_s_u_l_t_P_t_r->_t_y_p_e to either TCL_INT or TCL_DOUBLE to
  92.      indicate which value was set.  Under normal circumstances _p_r_o_c should
  93.      return TCL_OK.  If an error occurs while executing the function, _p_r_o_c
  94.      should return TCL_ERROR and leave an error message in _i_n_t_e_r_p->_r_e_s_u_l_t.
  95.  
  96.  
  97. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  98.      expression, mathematical function
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.